package org.example.day10;

/**
 * 3.3.3: ThreadLocal的初始值为null
 *      可以通过继承ThreadLocal来设置自定义的初始值
 */
public class MyThread3 extends ThreadLocal{
    @Override
    protected Object initialValue() {
        return "初始化默认值";
    }

    public static  MyThread3 t1 = new MyThread3();

    public static void main(String[] args) {
        if(t1.get() == null){
            System.out.println("没有初始值");
            t1.set("我的值");
        }
        System.out.println(t1.get());
        System.out.println(t1.get());
    }
}
